const { Controller } = require("egg");

class adminController extends Controller {
    async login() {
        try {
            const body = this.ctx.request.body

            let token = await this.ctx.service.user.login(body.username, body.password)
            if (token) {
                this.ctx.body = {
                    code: 20000,
                    message: true,
                    token,
                }
            } else {
                this.ctx.body = {
                    code: 50000,
                    message: "服务器错误",
                }
            }
        } catch (error) {
            this.ctx.body = {
                code: 40000,
                message: false
            }
        }
    }
}

module.exports = adminController